package business
{
	import com.adobe.cairngorm.business.ServiceLocator;
	
	import mx.collections.ItemResponder;
	import mx.rpc.AsyncToken;
	import mx.rpc.remoting.RemoteObject;	
	
	public class AdminUserDelegate
	{
		private var responder:Object;
        private var service:RemoteObject;		
		
		public function AdminUserDelegate(re:Object)
		{
	        this.service = ServiceLocator.getInstance().getRemoteObject("adminUserService");
            this.responder = re;			
		}
		
        public function login(name:String, password:String):void
        {
            var token:AsyncToken;
            var itemResponder:ItemResponder;
            token = service.login(name,password);
            itemResponder = new ItemResponder(responder["loginResult"],responder["fault"] );
            token.addResponder(itemResponder);          
        }
        
        public function update(updateObj:Object):void
        {
            var token:AsyncToken;
            var itemResponder:ItemResponder;
            token = service.update(updateObj);
            itemResponder = new ItemResponder(responder["updateResult"],responder["fault"] );
            token.addResponder(itemResponder);        
        } 		

		public function getUser(page:int):void
		{
            var token:AsyncToken;
            var itemResponder:ItemResponder;
            token = service.getUser(page);
            itemResponder = new ItemResponder(responder["getUserResult"],responder["fault"] );
            token.addResponder(itemResponder);  			
		}
		
		public function addUser(addObj:Object):void
		{
            var token:AsyncToken;
            var itemResponder:ItemResponder;
            token = service.addUser(addObj);
            itemResponder = new ItemResponder(responder["addUserResult"],responder["fault"] );
            token.addResponder(itemResponder); 		
		}

		public function delUserById(id:int):void
		{
            var token:AsyncToken;
            var itemResponder:ItemResponder;
            token = service.delUserById(id);
            itemResponder = new ItemResponder(responder["delUserByIdResult"],responder["fault"] );
            token.addResponder(itemResponder); 		
		}

		public function search(searchObj:Object):void
		{
            var token:AsyncToken;
            var itemResponder:ItemResponder;
            token = service.search(searchObj);
            itemResponder = new ItemResponder(responder["searchResult"],responder["fault"] );
            token.addResponder(itemResponder); 		
		}
		
		public function getAllUsers():void
		{
            var token:AsyncToken;
            var itemResponder:ItemResponder;
            token = service.getAllUsers();
            itemResponder = new ItemResponder(responder["getAllUsersResult"],responder["fault"] );
            token.addResponder(itemResponder); 				
		}		

	}
}